using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class Door : MonoBehaviour
{
    public int doorNumber;
    public string targetScene;
    private void Start()
    {
        GameObject player = GameObject.FindWithTag("Player");
        if (player.GetComponent<PlayerController>().doorNumber == doorNumber)
        {
            player.transform.position = transform.position;
        }
    }
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "Player")
        {
            other.GetComponent<PlayerController>().doorNumber = doorNumber;
            other.GetComponent<PlayerController>().nowScene = targetScene;
            SceneManager.LoadScene(targetScene);
        }
    }
}
